<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateMonthlyAttendanceReportsTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('monthly_attendance_reports', function (Blueprint $table) {
            $table->increments('id');
			$table->unsignedInteger('company_id')->index()->comment('公司ID');
			$table->unsignedInteger('project_id')->index()->comment('项目ID');
			$table->string('project_name')->index()->comment('项目名称');
			$table->year('year')->index()->comment('年份');
			$table->string('month')->index()->comment('月份');
            $table->unsignedInteger('user_id')->index()->comment('用户ID');
            $table->string('user_name')->index()->comment('姓名');
            $table->string('position')->index()->comment('岗位');
            $table->string('day_01',10)->nullable()->comment('第1天');
            $table->string('day_02',10)->nullable()->comment('第2天');
            $table->string('day_03',10)->nullable()->comment('第3天');
            $table->string('day_04',10)->nullable()->comment('第4天');
            $table->string('day_05',10)->nullable()->comment('第5天');
            $table->string('day_06',10)->nullable()->comment('第6天');
            $table->string('day_07',10)->nullable()->comment('第7天');
            $table->string('day_08',10)->nullable()->comment('第8天');
            $table->string('day_09',10)->nullable()->comment('第9天');
            $table->string('day_10',10)->nullable()->comment('第10天');
            $table->string('day_11',10)->nullable()->comment('第11天');
            $table->string('day_12',10)->nullable()->comment('第12天');
            $table->string('day_13',10)->nullable()->comment('第13天');
            $table->string('day_14',10)->nullable()->comment('第14天');
            $table->string('day_15',10)->nullable()->comment('第15天');
            $table->string('day_16',10)->nullable()->comment('第16天');
            $table->string('day_17',10)->nullable()->comment('第17天');
            $table->string('day_18',10)->nullable()->comment('第18天');
            $table->string('day_19',10)->nullable()->comment('第19天');
            $table->string('day_20',10)->nullable()->comment('第20天');
            $table->string('day_21',10)->nullable()->comment('第21天');
            $table->string('day_22',10)->nullable()->comment('第22天');
            $table->string('day_23',10)->nullable()->comment('第23天');
            $table->string('day_24',10)->nullable()->comment('第24天');
            $table->string('day_25',10)->nullable()->comment('第25天');
            $table->string('day_26',10)->nullable()->comment('第26天');
            $table->string('day_27',10)->nullable()->comment('第27天');
            $table->string('day_28',10)->nullable()->comment('第28天');
            $table->string('day_29',10)->nullable()->comment('第29天');
            $table->string('day_30',10)->nullable()->comment('第30天');
            $table->string('day_31',10)->nullable()->comment('第31天');
            $table->integer('days')->default(0)->comment('出勤天数');
            $table->integer('holidays')->default(0)->comment('节假日加班天数');
            $table->unique(['project_id', 'year', 'month', 'user_id']);
            $table->timestamps();
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('monthly_attendance_reports');
    }
}
